#include <ir/reg.h>

namespace ir {

  Reg::Reg(int id, VarType _type): type(_type) {
    this->name = std::string("l") + std::to_string(id);
    this->used_count = 0;
  }

  std::string Reg::get_name() {
    return this->name;
  }

  VarType Reg::get_type() {
    return this->type;
  }

  void Reg::add_used_count() {
    this->used_count++;
  }

  void Reg::sub_used_count() {
    this->used_count--;
  }

  bool Reg::if_used() {
    if(this->used_count > 0) return true;
    else return false;
  }
}
